package Top200;

import common.ListNode;

/**
 * @author zhangmin
 * @create 2022-02-26 13:16
 */
public class deleteDuplicates82 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head==null||head.next==null) return head;
        ListNode newhead=new ListNode(-101);
        newhead.next=head;
        ListNode p=newhead;
        while (p.next!=null&&p.next.next!=null){
            if (p.next.val==p.next.next.val){
                int x=p.next.val;
                while (p.next!=null&&p.next.val==x){
                    p.next=p.next.next;
                }
            }else {
                p=p.next;
            }
        }
        return newhead.next;
    }
}
